package com.wang.socket;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;

import java.io.UnsupportedEncodingException;

public class OutBoundHandler extends ChannelHandlerAdapter {

    /*  public static void outData(String devGId,String msg) throws UnsupportedEncodingException {
          ChannelHandlerContext ctx = SocketMap.regPassDeviceMap.get(devGId).getCtx();
  
          ByteBuf resp = Unpooled.copiedBuffer(msg.getBytes("GBK"));
          ctx.write(resp);
          ctx.flush();
  
          System.out.println("发送成功");
  
  
      }*/
    public static void outData(ChannelHandlerContext ctx, byte[] data) {

        ctx.write(Unpooled.wrappedBuffer(data));
        ctx.flush();

    }

    public static void outData(ChannelHandlerContext ctx, String data) throws UnsupportedEncodingException {

        ByteBuf resp = Unpooled.copiedBuffer(data.getBytes("GBK"));
        ctx.write(resp);
        ctx.flush();

    }
}
